import 'package:flutter/material.dart';
import 'package:get/get.dart';

class Test_class_status extends StatelessWidget {
  Test_class_status({super.key});
  final person = Person('123', 123, Bag('123'));
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: const Text('Test_class_status')),
        body: Column(children: [

          Obx(() {
            return    Text('name:${person.name.value}');
          }),
          ElevatedButton(
              onPressed: () {
                person.name.value = person.name.value.toUpperCase();
              },
              child: const Text('切换名称')),
       Obx(() {
         return    Text('age:${person.age}');
       }),
          ElevatedButton(onPressed: () {
            person.age++;
          }, child: Text('年龄+1'),)
        ]));
  }
}

class Person {
  final name;
  int age;
  final bag;

  Person(this.name, this.age, this.bag);

  @override
  String toString() {
    return 'Person{name: $name, age: $age, bag: $bag}';
  }
}

class Bag{
  String id;
  Bag(this.id);

  @override
  String toString() {
    return 'Bag{id: $id}';
  }
}